import { post, get } from '@/request/http'
import { toString } from '@/utils/utils'
import store from '@/store'

/**
 * 平台管理-- 岗位角色管理 接口
 *
 */


/**
 * 获取列表数据
 */
export const checkSysroleList = (data) =>
  post(
    '/FTKJWLHYPT/platform/queryRole',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            rleCUuid: data.rleCUuid,
            rleName: data.rleName,
            fltUuid: store.state.user.FLT_UUID_DX_H
          }
        },
        PageIndex: {
          FTKJWLHYPT: data.currentPage
        },
        PageSize: {
          FTKJWLHYPT: data.pageSize
        }
      }
    }
  )

/**
 * 新增一行数据
 */
export const AddSysRole = ({
  // 必填
  rleCode,
  rleName,
  rleCUuid,
  remark
}) =>
  post(
    '/FTKJWLHYPT/platform/addRole',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            rleCode,
            rleName,
            rleCUuid,
            remark,
            creator: store.state.user.USR_CODE_DX_H,
            fltUuid: store.state.user.FLT_UUID_DX_H
          }
        }
      }
    }
  )
/**
 * 编辑一行数据
 */

export const editSysrole = ({
  rleCode,
  uuid,
  rleName, // 角色名称
  rleCUuid, // 角色类型
  version, // 版本号
  // 非必填
  remark, // 备注
  fltUuid
}) =>
  post(
    '/FTKJWLHYPT/platform/editRole',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            rleCode,
            rleName,
            rleCUuid,
            uuid,
            // 非必填
            remark, // 备注
            fltUuid: fltUuid,
            lastModifier: store.state.user.USR_CODE_DX_H,
            version: toString(version),
          }
        }
      }
    }
  )
/**
 * 删除一行数据
 */

export const delSysrole = ({
  uuid, //
  fltUuid
}) =>
  post(
    '/FTKJWLHYPT/platform/deleteRole',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            uuid,
            lastModifier: store.state.user.USR_CODE_DX_H,
            fltUuid: fltUuid
            // version: toString(version),
            // fltUuid: store.state.user.fltUuid_DX_H
          }
        }
      }
    }
  )

// 角色类型下拉框
export const getroleList = () => get('/FTKJWLHYPT/platform/queryRoleType')


